# 基于[windows server core]镜像
#FROM openjdk:8-jdk-windowsservercore
FROM microsoft/windowsservercore:latest
MAINTAINER pancy.fan@avatech.com.cn

# 拷贝程序包

# COPY ["packages/application.yml", "C:/diservice/application.yml"]

# 拷贝程序包
ADD ["packages/Windows.tar.gz", "C:/"]
ADD ["packages/SqlNativeClient.tar.gz", "C:/packages/"]
ADD ["packages/Prerequisites.tar", "C:/packages/Prerequisites/"]
ADD ["packages/DI API.tar", "C:/packages/DI API/"]
#ADD ["packages/demo-0.0.1-SNAPSHOT.jar","C:/diservice/app.jar"]


# 使用Powershell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]


ENV JAVA_HOME "C:\Program Files\Java\jdk1.8.0_202"

## 安装jdk

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;\
	Invoke-WebRequest -Uri "https://mirrors.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-windows-x64.exe" -OutFile 'C:\packages\openjdk.exe'; \
    Start-Process -FilePath 'C:\packages\openjdk.exe' -ArgumentList "/qn" -Wait -NoNewWindow -PassThru; 
   
	
RUN SETX /m JAVA_HOME ${ENV:JAVA_HOME};
RUN SETX /m PATH $(${ENV:PATH} + \";${ENV:JAVA_HOME}\bin\"+\";${ENV:JAVA_HOME}\jre\bin\");

# 安装程序包
RUN Start-Process -FilePath msiexec -ArgumentList "/i",'C:\packages\Prerequisites\ISSetupPrerequisites\{9B88FC3F-9777-47F9-BDAB-B669D7A7E821}\vcredist.msi',"/qn" -Wait -NoNewWindow -PassThru; \
    Start-Process -FilePath msiexec -ArgumentList "/i",'C:\packages\sqlncli_x86.msi',"/qn","IACCEPTSQLNCLILICENSETERMS=YES" -Wait -NoNewWindow -PassThru; \
    Start-Process -FilePath msiexec -ArgumentList "/i",'C:\packages\sqlncli_x64.msi',"/qn","IACCEPTSQLNCLILICENSETERMS=YES" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{83960519-644A-4722-BA7A-37D23C1D004F}\vcredist_x86.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{8A102FA5-9E73-477b-8937-2ED4C06AF304}\vcredist_x64.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{09F56021-05C8-46A2-BCD8-DBF87ED5C928}\vcredist_x86.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{49CE81AF-01AB-4DE6-8995-598B5F682F66}\vcredist_x64.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{9A410431-2D9E-44B5-B005-05930324B208}\VC_redist.x86.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{915387C3-E260-4985-861D-E7A891A4F73B}\vc_redist.x64.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{EFE44567-D253-42D2-B146-AED461A0B3F5}\VC_redist.x64.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	#Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{9A410431-2D9E-44B5-B005-05930324B208}\VC_redist.x86.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
	#Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\VC_redist.x86.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
    #Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{8A102FA5-9E73-477b-8937-2ED4C06AF304}\vcredist_x64.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
    #Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{83960519-644A-4722-BA7A-37D23C1D004F}\vcredist_x86.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
    Start-Process -FilePath 'C:\packages\Prerequisites\ISSetupPrerequisites\{C4366B56-BE8F-41DA-AEFC-CB5165ADB5D3}\NDP452-KB2901907-x86-x64-AllOS-ENU.exe' -ArgumentList "/q" -Wait -NoNewWindow -PassThru; \
    Start-Process -FilePath 'C:\packages\DI API\setup.exe' -ArgumentList "/S","/v/qn" -Wait -NoNewWindow -PassThru
   
 

# 删除程序包
SHELL ["cmd", "/S", "/C"]
#RUN RD /S /Q "C:/packages/"

EXPOSE 8082
#ENTRYPOINT java -Xmx256m -Xms256m -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 -jar /diservice/app.jar

#docker build --force-rm --no-cache -f . -t diservice:9.3